package cn.wizzer.app.crown.modules.models;

import cn.wizzer.app.crown.modules.models.enums.SettleStatusEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.integration.json4excel.annotation.J4EIgnore;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 投资
 */

@Data
@Table("crown_order")
@TableIndexes({@Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false),
        @Index(name = "unique_no", fields = {"no"}, unique = true),
        @Index(name = "INDEX_BET_ID", fields = {"betId"}, unique = false),
        @Index(name = "INDEX_USER_ID", fields = {"userId"}, unique = false)})
public class CrownOrder extends BaseModel implements Serializable {


    @Column
    @Name
    @Comment("ID")
    @J4EIgnore
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;


    @Column
    @Comment("玩法ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String betId;

    @Column
    @Comment("订单编号")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String no;


    @Column
    @Comment("赔率")
    @ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
    private BigDecimal rate;

    @Column
    @Comment("投资金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 2)
    private BigDecimal amount;

    @Column
    @Comment("中奖金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 2)
    private BigDecimal resultAmount;

    @Column
    @Comment("状态->WAIT_SETTLE:待结算,SETTLED:已结算,CANCELLED:已取消")
    @ColDefine(type = ColType.VARCHAR, width = 12)
    private SettleStatusEnum status;

    @Column
    @Comment("服务费")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 2)
    private BigDecimal serviceFee;

    @Column
    @Comment("是否中奖")
    @ColDefine(type = ColType.BOOLEAN)
    @Default(value = "false")
    private Boolean result;



    @Column
    @Comment("是否体验金投资")
    @ColDefine(type = ColType.BOOLEAN)
    @Default(value = "false")
    private Boolean expInvest;


    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    private Long ctAt;


    @Column
    @Comment("结算时间")
    private Long settleAt;
}